Unexpected '{' with IF statement

Posted by user1926208 on Stack Overflow See other posts from Stack Overflow or by user1926208
Published on 2013-06-24T22:13:27Z Indexed on 2013/06/24 22:21 UTC
Read the original article Hit count: 90

Filed under:

this is my code to move all the files in a directory to another directory which are 1 hour old or more.

<?php
$srcDir = 'code';
$destDir = 'code/old';

if (file_exists($destDir)) {
  if (is_dir($destDir)) {
    if (is_writable($destDir)) {
      if ($handle = opendir($srcDir)) {
        while (false !== ($file = readdir($handle))) {
          if (is_file($srcDir . '/' . $file)) {
              if(date("U",filectime($srcDir . '/' . $file) >= time() - 3600) {
                rename($srcDir . '/' . $file, $destDir . '/' . $file);
                }

          }
        }
        closedir($handle);
      } else {
        echo "$srcDir could not be opened.\n";
      }
    } else {
      echo "$destDir is not writable!\n";
    }
  } else {
    echo "$destDir is not a directory!\n";
  }
} else {
  echo "$destDir does not exist\n";
}
?>

and I am getting this error:

Parse error: syntax error, unexpected '{' in /home/tcity/public_html/myDir/movefiles.php on line 11

© Stack Overflow or respective owner

Related posts about php